#include<cstdio>
using namespace std;
int n,m,k;
int L,R;
signed main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&L,&R);
	if(L==R){
		printf("%d\n",L%n);
		return 0;
	}
	int l=L%n;
	int k=n-1-l;
	int r=R%n;
	
	if(L+k<=R){
		printf("%d\n",n-1);
	}
	else{
		printf("%d\n",r);
	}
	return 0;
}
